package com.fh.shop.api.util;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class SMSUtil {

    private static final String url = "https://api.netease.im/sms/sendcode.action";
    private static final String AppKey = "958684b56af8560efdbe101960eab916";
    private static final String AppSecret = "4933d706a25e";

    public static String sendMsg(String phone) {
        // 头参数
        Map<String, String> headers = new HashMap<>();
        headers.put("AppKey", AppKey);
        String nonce = UUID.randomUUID().toString();
        headers.put("Nonce", nonce);
        String date = new Date().getTime() + "";
        headers.put("CurTime", date);
        String checkSum = CheckSumBuilder.getCheckSum(AppSecret, nonce, date);
        headers.put("CheckSum", checkSum);
        // 普通参数
        Map<String, String> params = new HashMap<>();
        params.put("mobile", phone);
        // 调用工具类
        String s = HttpClientUtil.sendPost(url, headers, params);
        return s;
    }
}
